package cn.itcast.order;

import cn.itcast.feign.client.UserClient;
import cn.itcast.feign.config.FeignClientConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @author wl
 */
@SpringBootApplication
@MapperScan("cn.itcast.order.mapper")
@EnableFeignClients(clients = UserClient.class, defaultConfiguration = FeignClientConfig.class)
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  订单模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                "          (`-')  _           \n" +
                "   <-.    ( OO).-/     .->   \n" +
                " ,--. )  (,------.(`-')----. \n" +
                " |  (`-') |  .---'( OO).-.  '\n" +
                " |  |OO )(|  '--. ( _) | |  |\n" +
                "(|  '__ | |  .--'  \\|  |)|  |\n" +
                " |     |' |  `---.  '  '-'  '\n" +
                " `-----'  `------'   `-----' ");

    }

    /**
     * 创建RestTemplate并自动注入到Spring容器中
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 作用于全局的修改负载均衡的规则，
     * 也可写一个配置类，作用于局部
     */
//    @Bean
//    public IRule randomRule() {
//        return new RandomRule();
//    }

}
